<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 【案例】使用reduce实现数组去重
        var arr = [6,6,6,1,2,3,4,3,3,2,3,5,5,5,5]

        var res= arr.reduce(function(pre,cur){ 
            // 循环pre
            for(var i = 0; i <= pre.length ; i++){
                // 如果返回 -1，在pre添加cur
                if(pre.indexOf(cur) === -1){
                    pre.push(cur)
                    }
            }
            return pre
        },[])
        console.log(res)
    </script>
</body>
</html>